import Vue from 'vue'
import Router from 'vue-router'
import NProgress from 'nprogress';
import 'nprogress/nprogress.css'
import HelloWorld from '@/components/HelloWorld'


//解决router-link点击相同路由报错
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '/index',
      redirect: '/home',
      name: 'Index',
      component: () => import('../views/Index'),
      children: [


        {
          path: '/home',
          name: 'home',
          component: () => import('../views/Home')
        },
        {
          path: '/gamelist',
          name: 'GameList',
          component: () => import('../views/GameList')
        },
        {
          path: '/cart',
          name: 'cart',
          component: () => import('../views/Cart')
        },

        {
          path: '/submit',
          name: 'submit',
          component: () => import('../views/Submit')
        },
        {
          path: '/main',
          name: 'main',
          component: () => import('../views/Main')
        }
      ]
    },
    {
      path: '/detail/:id',
      name: 'detail',
      component: () => import('../views/Detail')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/Register')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Login')
    },
    {
      path: '/usermessage',
      name: 'usermessage',
      component: () => import('../views/Usermessage')
    },
    {
      path: '/addr',
      name: 'addr',
      component: () => import('../views/Addr')
    },
    {
      path: '/edit',
      name: 'edit',
      component: () => import('../views/Edit')
    },
    {
      path: '/bind',
      name: 'bind',
      component: () => import('../views/Bind')
    },
    {
      path: '/newphone',
      name: 'newphone',
      component: () => import('../views/Newphone')
    },
    {
      path: '/newpsw',
      name: 'newpsw',
      component: () => import('../views/Newpsw')
    },
    {
      path: '/coupon',
      name: 'coupon',
      component: () => import('../views/Coupon')
    },
    {
      path: '/look',
      name: 'look',
      component: () => import('../views/Look')
    },
    {
      path: '/like',
      name: 'like',
      component: () => import('../views/Like')
    }

  ]
})
